//
// Created by shen on 2025/2/27.
//

#ifndef VIDEOEDIT_AVFRAMEQUEUE_H
#define VIDEOEDIT_AVFRAMEQUEUE_H

#include "LogUtil.h"
#include "SWorkStatus.h"
#include "queue"
extern "C"{
#include "libavcodec/avcodec.h"
};

typedef struct frameStruct{
    uint8_t *yData;
    uint8_t *uData;
    uint8_t *vData;
    double pts;
};
class AVFrameQueue {
public:

    explicit AVFrameQueue(FFStatus *ffStatus);

    virtual ~AVFrameQueue();

public:


    int putAvFrame(AVFrame *avFrame);
    int putStructAvFrame(frameStruct *structFrame);
    int getAvFrameByTime(AVFrame *avFrame,double timestamp,AVRational bastTime);
    int getAvFrame(AVFrame *avFrame);
    int getStructAvFrame(frameStruct **structFrame,double timestamp,AVRational bastTime);
    int getQueueSize();
    void clearAvPacket();
    void noticeQueue();

public:
    std::queue<AVFrame *> queuePacket;
    std::queue<frameStruct *> structQueuePacket;
    std::mutex mutex;
    std::condition_variable cond;
    FFStatus *ffStatus;
};


#endif //VIDEOEDIT_AVFRAMEQUEUE_H
